$("#topFrname").delegate('span', 'click', function () {
    var this_text = $(this).text();
    var this_ids = $(this).data('ids');
    $(this).remove();
    var app_html = "<span data-ids='" + this_ids + "'><strong class='iconfont'>&#xe601;</strong><b>" + this_text + "</b></span>";
    $("#bottomFrname").prepend(app_html);
});

$("#bottomFrname").delegate('strong', 'click', function () {
    var this_text = $(this).siblings('b').text();
    var this_ids = $(this).parent().data('ids');
    $(this).parent('span').remove();
    var app_html = "<span data-ids='" + this_ids + "'>" + this_text + "</span>";
    $("#topFrname").prepend(app_html);
});
$("#choice span").click(function () {
    $(this).removeClass('active');
    $(this).siblings('span').addClass('active');
})
$("#mainCenter dl dt span").click(function () {
    var state = $(this).data('state1');
    var state2 = $(this).data('state2');
    if (state == '1') {
        $(this).css("color", "red");
        $(this).data("state1", "0");
        if (state2 == 'Y') {
            $('.appoint dt span').css("color", "#000");
            $('.option dt span').data("state1", "1");
            var yes_state = new Array();
            $('body #topFrname span').each(function (key) {
                yes_state[key]['text'] = $(this).text();
                yes_state[key]['ids'] = $(this).data('ids');
            });
            $("#topFrname").html(' ');
            var html_app = '';
            for (var i = 0; i < yes_state.length; i++) {
                html_app += "<span data-ids='" + yes_state[i]['ids'] + "'><strong class='iconfont'>&#xe601;</strong><b>" + yes_state[i]['text'] + "</b></span>";
            }
            $("#bottomFrname").append(html_app);
        } else {
            $('.option dt span').css("color", "#000");
            $('.appoint dt span').data("state1", "1");
            var no_state = new Array();
            $('body #bottomFrname b').each(function (key) {
                no_state[key]['text'] = $(this).text();
                no_state[key]['ids'] = $(this).pranet().data('ids');
            });
            $("#bottomFrname").html(' ');
            var html_app1 = '';
            for (var a = 0; a < no_state.length; a++) {
                html_app1 += "<span data-ids='" + no_state[a]['ids'] + "'>" + no_state[a]['text'] + "</span>";
            }
            $("#topFrname").append(html_app1);
        }
    } else {
        $(this).css("color", "#000");
        $(this).data("state1", "1");
    }
})
$("#mainCenter dl dt strong").click(function () {
    $("#topFrname").html(' ');
});
$("#choice strong").click(function () {
    $(this).hide();
    $(this).siblings('strong').show();
    var state = $(this).data('state2');
    if (state == 'N') {
        $(this).siblings('ul').slideUp('3000');
    } else {
        $(this).siblings('ul').slideDown('3000');
    }
})
//$(window).load(function(){
//    
//})

$('#choice span').click(function () {
    var choice_ids = new Array();
    var choice_idss = new Array();
    $('body #topFrname span').each(function (key) {
        choice_ids[key] = $(this).data('ids');
    });
    $('body #bottomFrname span').each(function (keys) {
        choice_idss[keys] = $(this).data('ids');
    });
    var choice_str = choice_ids.join();
    var choices_str = choice_idss.join();
    var choices = choice_str + ',' + choices_str;
    var ids = $(this).parent('li').data('ids');
    $.ajax({
        url: 'http://admin.daizhang.me/Admin/Platform/choiceAjax',
        type: "get",
        dataType: "html",
        data: {
            id: ids,
            choice: choices
        },
        success: function (data) {
            $("#topFrname").append(data);
        },
        error: function () {

        }
    });
})


$("body #confButton").click(function () {
    $("#frameBor").fadeIn('2000');
})
$("body #closeSpan").click(function () {
    //选择的分类ID
    var class_ids_arr = new Array();
    $('body #choice span.active').each(function (key) {
        if ($(this).data('actone') == 'N') {
            class_ids_arr[key] = $(this).parent().data('ids');
        }
    });
    var class_ids_str = '';
    for (var i = 0; i <= class_ids_arr.length; i++) {
        if (!class_ids_arr[i] || class_ids_arr[i] == '') {
            class_ids_str += '';
        } else {
            class_ids_str += class_ids_arr[i] + ',';
        }
    }
    class_ids_str = class_ids_str.substring(0, class_ids_str.length - 1);
    //选择的商品ID
    var shop_id_arr = new Array();
    $('body #bottomFrname span').each(function (keys) {
        shop_id_arr[keys] = $(this).data('ids');
    })
    var shop_ids = shop_id_arr.join();
    $("#classIds").val(class_ids_str);
    $("#goodsIds").val(shop_ids);
    $("#frameBor").slideUp('2000');
})
